<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>判断星座</title>
</head>
<body>
<input placeholder="请输入出生月份" id="a">
<input placeholder="请输入出生日期" id="b">
<input type="button" value="搜索" onclick="show()">
<div id="dl"></div>
<script>



function show() {
    if (a.value==1) {
        if(b.value>=20&&b.value<=31){      // 1.20   2.18
           dl.innerHTML="水瓶座";
        }else if (b.value>=1&&b.value<20) {
            dl.innerHTML="摩羯座";
        }else {
          alert("输入有误！");
        }
    }
    if (a.value==2) {
        if(b.value>=1&&b.value<=18){       // 2.19  3.20
            dl.innerHTML="水瓶座";
        }else if (b.value>=19&&b.value<=29) {
            dl.innerHTML="双鱼座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==3) {
        if(b.value>=1&&b.value<=20){                 // 3.21        4.19
            dl.innerHTML="双鱼座";
        }else if (b.value>=21&&b.value<=30) {
            dl.innerHTML="白羊座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==4) {
        if(b.value>=1&&b.value<=20){             // 4.20  5.20
            dl.innerHTML="白羊座";
        }else if (b.value>=20&&b.value<=31) {
            dl.innerHTML="金牛座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==5) {
        if(b.value>=1&&b.value<=20){        //5.21          6.21
            dl.innerHTML="金牛座";
        }else if (b.value>=21&&b.value<=31) {
            dl.innerHTML="双子座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==6) {
        if(b.value>=1&&b.value<=21){            //6.22      7.22
            dl.innerHTML="双子座";
        }else if (b.value>=22&&b.value<=30) {
            dl.innerHTML="巨蟹座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==7) {
            if(b.value>=1&&b.value<=22){      // 7.23      8.22
            dl.innerHTML="巨蟹座";
        }else if (b.value>=23&&b.value<=31) {
            dl.innerHTML="狮子座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==8) {
        if(b.value>=1&&b.value<=22){            //8.23          9.22
            dl.innerHTML="狮子座";
        }else if (b.value>=23&&b.value<=31) {
            dl.innerHTML="处女座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==9) {
        if(b.value>=1&&b.value<=22){                //9.23      10.23
            dl.innerHTML="处女座";
        }else if (b.value>=23&&b.value<=30) {
            dl.innerHTML="天秤座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==10) {
        if(b.value>=1&&b.value<=23){                //10.24         11.22
            dl.innerHTML="天秤座";
        }else if (b.value>=24&&b.value<=30) {
            dl.innerHTML="天蝎座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==11) {
        if(b.value>=1&&b.value<=22){                //11.23  12.21
            dl.innerHTML="天蝎座";
        }else if (b.value>=23&&b.value<=30) {
            dl.innerHTML="射手座";
        }else {
            alert("输入有误！");
        }
    }
    if (a.value==12) {
        if(b.value>=22&&b.value<=31){               //12.22    1.19
            dl.innerHTML="摩羯座";
        }else if (b.value>=1&&b.value<20) {
            dl.innerHTML="水瓶座";
        }else {
            alert("输入有误！");
        }
    }

}
</script>
</body>
</html>